home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / st80_r41.lha / st80_r41 / Controller-poll_BugFix.st < prev    next >
Text File  |  1993-07-23  |  2KB  |  67 lines

  1. '    NAME        Controller-poll_BugFix.st
  2.         AUTHOR          Bill Voss (voss@cs.uiuc.edu)
  3.         FUNCTION    Fixes a race condition in Controller under R4.1
  4.         ST-VERSIONS     ST80 R4.1
  5.     PREREQUISITES    none
  6.     DISTRIBUTION      world
  7.     VERSION    ID    1
  8.     VERSION DATE    August 22nd, 1992
  9.     SUMMARY
  10.  
  11. Date: Sat, 22 Aug 1992 13:55:07 -0500
  12. From: Bill Voss <voss@cs.uiuc.edu>
  13. To: support@parcplace.com
  14. Subject: BugReport (and fix)
  15.  
  16. Under ParcRanger at the University of Illinois in Urbana/Champaign.
  17. Smalltalk version Objectworks\Smalltalk(R), Release 4.1 of 15 April 1992
  18. ChangeSet patches OrderedCollection ()
  19. Running on a SUN SparcStation 2 running SUNOS 4.1.2 under OW 3 using tvtwm.
  20.  
  21. I found a race condition.  
  22. My code invokes DialogView confirm:initialAnswer: in a process running
  23. at lowIOPriority.  When I pressed-then-released the mouse button instead 
  24. of rapidly clicking the mouse button I usually got the notifier.
  25.  
  26. Unhandled exception: Message not understood: #isInTransition:
  27. copy stack 
  28. UndefinedObject(Object)>>doesNotUnderstand:
  29. [] optimized
  30. WidgetController>>controlLoopBody
  31. WidgetController>>controlLoop
  32. WidgetController(Controller)>>startUp
  33. ActionButton(VisualPart)>>startUp
  34. DialogController(Controller)>>controlToNextLevel
  35. DialogController>>controlActivity
  36. DialogController(Controller)>>controlLoop
  37.  
  38. The optimized [] is from WidgetController beTriggerOnUp.
  39. The problem there is that view is undefined.
  40.  
  41. I eventually found that in WidgetController>>controlLoopBody
  42.     ...
  43.     [previousState := state.
  44.      view isNil ifTrue:[self halt].
  45.      self poll.
  46.      view isNil ifTrue:[self halt].  "<--- halts here"
  47.      state := self buttonPressed.
  48.     ...
  49.  
  50. My solution is
  51.  
  52. From Objectworks\Smalltalk(R), Release 4.1 of 15 April 1992 on 22 August 1992 at 1:17:27 pm'!
  53.  
  54. !Controller methodsFor: 'basic control sequence'!
  55.  
  56. poll
  57.         "Announce that we are iterating through the polling loop.  If
  58.         there has been no input for a significant time, wait on a semaphore"
  59.  
  60.         ScheduledControllers checkForEvents.
  61.         self view == nil                "if the top view was closed"
  62.                 ifTrue: [ScheduledControllers class closedWindowSignal raiseRequest].
  63.         self sensor pollForActivity.   "pollForActivity may invoke 'Processor yield'"
  64.         self view == nil               "check again because we may have lost a race."
  65.                 ifTrue: [ScheduledControllers class closedWindowSignal raiseRequest]! !
  66.  
  67.